//S = "aba", T = "abb"
//S = "abcd", T = "efg"
//S = "xyz", T = "xy"
S = "hello", T = "helloworld"

function solution(S, T) {
    let Tfront = ''
    let min = S.length
    let len = T.length
    for (let i = 0; i < len; i++) {
        Tfront += T[i]
        //console.log(Tfront);
        let cut = Cut(S, Tfront)
        //console.log(cut);
        if (cut < min) min = cut
    }
    return min
}
function Cut(S, Tfront) {
    let n = S.length
    let m = Tfront.length
    let cutLen = n - m
    for (let i = 0; i < m; i++) {
        if (S[i] !== Tfront[i]) {
            cutLen++
        }
    }
    return cutLen
}
console.log(solution(S, T));
